/*
 *  BinaryEqualityOperatorAst.cpp
 *  TempWorking
 *
 *  Created by Piotr Holc on 20/11/2010.
 *  Copyright 2010 Langerra Limited. All rights reserved.
 *
 */

#include <MAlice/Ast/BinaryEqualityOperatorAst.h>

namespace MAlice {
	
	BinaryEqualityOperatorAst::BinaryEqualityOperatorAst(ExpressionAst* lhs,
														 ExpressionAst* rhs) : BinaryOperatorAst("==", lhs, rhs) {}
	
	BinaryEqualityOperatorAst::~BinaryEqualityOperatorAst() {
	}
	
	llvm::Value* BinaryEqualityOperatorAst::generate()
	{
		llvm::Value* LHS = getLHS()->generate();
		llvm::Value* RHS = getRHS()->generate();
		
		checkType(LHS, RHS);
		
		Builder* builder = MAlice::Codegen::get()->getBuilder();
		
		return builder->CreateICmpEQ(LHS, RHS);
	}
	
}
